package com.runyun.project.util;

import java.time.LocalDate;
import java.util.Calendar;
import java.util.TimeZone;

public class TimeUtil {
    //获取今天十点半的时间戳//
    public static long getToday10Time(){
        Calendar calendar=Calendar.getInstance(TimeZone.getTimeZone("GMT+8"));
        calendar.set(Calendar.HOUR_OF_DAY,10);
        calendar.set(Calendar.MINUTE,30);
        calendar.set(Calendar.SECOND,00);
        return calendar.getTimeInMillis();
    }
    //获取今天凌晨的时间戳
    public static long getToday0Time(){
        Calendar calendar=Calendar.getInstance(TimeZone.getTimeZone("GMT+8"));
        calendar.set(Calendar.HOUR_OF_DAY,0);
        calendar.set(Calendar.MINUTE,0);
        calendar.set(Calendar.SECOND,0);
        return calendar.getTimeInMillis();
    }
    //获取昨天10点的时间戳
    public static long getYesterday10Time(){
        Calendar calendar=Calendar.getInstance(TimeZone.getTimeZone("GMT+8"));
        calendar.set(Calendar.HOUR_OF_DAY,10);
        calendar.set(Calendar.MINUTE,0);
        calendar.set(Calendar.SECOND,0);
        calendar.add(Calendar.DAY_OF_MONTH,-1);
        return calendar.getTimeInMillis();
    }
    //获取第二天凌晨的时间戳
    public static long getTomorrow0Time(){
        Calendar calendar=Calendar.getInstance(TimeZone.getTimeZone("GMT+8"));
        calendar.set(Calendar.HOUR_OF_DAY,0);
        calendar.set(Calendar.MINUTE,0);
        calendar.set(Calendar.SECOND,0);
        calendar.add(Calendar.DAY_OF_MONTH,+1);
        return calendar.getTimeInMillis();
    }
    //下周一的时间戳
    public static Long getNextMondayTime(){
        Calendar calendar=Calendar.getInstance(TimeZone.getTimeZone("GMT+8"));
        calendar.add(Calendar.WEEK_OF_YEAR, 1);
        calendar.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
        calendar.set(Calendar.HOUR_OF_DAY, 0);
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MILLISECOND, 0);
        return calendar.getTimeInMillis();
    }
    //获取今天是本月的第几号
    public static int getDayOfMonth() {
        LocalDate today = LocalDate.now();
        return today.getDayOfMonth();
    }
    //获取今天是周几
    public static int getDay(){
        Calendar calendar = Calendar.getInstance();
        int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK);
        return dayOfWeek-1;
    }



}
